﻿using System;
using System.Text;
using Common.Service;
using System.Data;

namespace Task
{
    public partial class getAllTask : System.Web.UI.Page
    {
        Task.Common.Interface.IDictionary dictionary = ServiceContainer.GetService<Task.Common.Interface.IDictionary>();
        private string content = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            if (!IsPostBack)
            {
                if (Request.QueryString["PdId"] != null)
                {
                    GetProcessType(Request.QueryString["PdId"]);
                }
                else
                {
                    GetProcessType("0");
                }
                Response.Write(content);
            }
            Response.End();
        }
        public void GetProcessType(string PdId)
        {

            StringBuilder sb = new StringBuilder();

            if (PdId == "0")
            {
                //流程类型
                DataTable dtTypeName = dictionary.GetDictionaryData("DictionaryLogic_GetListByType", "type!PROCESS_CATEGORY;").Tables[0];
                for (int p = 0; p < dtTypeName.Rows.Count; p++)
                {
                    string pcTypeName = dtTypeName.Rows[p]["CN_NAME"].ToString();
                    string ID = dtTypeName.Rows[p]["DICTIONARY_ID"].ToString();
                    DataTable dt = dictionary.GetDictionaryData("DictionaryLogic_GetListByDicID", "parentID!" + ID).Tables[0];
                    sb.Append("<div style='width: 800px; float: left;'>");
                    sb.Append("<span style='float: left;height: 15px;'>" + pcTypeName + "</span>");
                    sb.Append("<b style='background: url(images/line2.png) 0 11px repeat-x; width: 600px; display: block;float: left; height: 15px;'></b>");
                    sb.Append("<div style='panding-top:10px'>&nbsp;</div><ul >");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string CN_NAME = dt.Rows[i]["CN_NAME"].ToString();
                        string DICTIONARY_ID = dt.Rows[i]["DICTIONARY_ID"].ToString();
                        sb.Append("<li style='width: 150px;border-right:0px;'><img src='images/fav1.png' onclick='' /><a>" + CN_NAME + "</a></li>");
                    }
                    sb.Append("</ul><div style='panding-top:10px'>&nbsp;</div></div>");
                    content = sb.ToString();
                }
            }
            else
            {
                DataTable dt = dictionary.GetDictionaryData("DictionaryLogic_GetListByDicID", "parentID!" + PdId).Tables[0];
                sb.Append("<ul >");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string CN_NAME = dt.Rows[i]["CN_NAME"].ToString();
                    string DICTIONARY_ID = dt.Rows[i]["DICTIONARY_ID"].ToString();
                    sb.Append("<li style='width: 150px;border-right:0px;'><img src='images/fav1.png' onclick='' /><a>" + CN_NAME + "</a></li>");
                }
                sb.Append("</ul>");
                content = sb.ToString();
            }
        }

    }
}